package com.example.springboot.mapper;

import com.example.springboot.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StudentMapper {
    @Select("SELECT * FROM student limit #{pageNum},#{pageSize}")
    List<Student> findAll(Integer pageSize,Integer pageNum);


    @Select("select count(*) from student ")
    Integer findCount();

//查询密码  通过不同的身份
    @Select("select password from student where student_id = #{userAccount}")
    String authenticate_student(Integer userAccount);
    @Select("select password from teacher where job_id = #{userAccount}")
    String authenticate_teacher(Integer userAccount );
    @Select("select password from admin where id = #{userAccount}")
    String authenticate_admin(Integer userAccount );
//查询 学生信息(个人中心)  : 学号 姓名  性别 院系  专业  密码  手机  邮箱
//
    @Select("SELECT * FROM student where student_id =#{id}")
    Student findStudent_msg(Integer id);

    @Update("update student set name = #{name},sex=#{sex},password = #{password},phone=#{phone} where student_id =#{student_id} ")
    int update_student(Student student);

    @Select("SELECT * FROM student where student_id =#{str}")
    List<Student> student_idSelect(String str);
    @Select("SELECT * FROM student where name like  #{str}")
    List<Student> student_name_like(String str);

    @Select("SELECT student.*,sper.sper_name FROM student ,sper where sper.sper_name = #{sper_name} and student.sper_code = sper.sper_code")
    List<Student> getStudentSper(String sper_name);
}
